home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mgr / lib / text.c < prev    next >
C/C++ Source or Header  |  1989-01-24  |  2KB  |  72 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: text.c,v 4.1 88/06/21 13:41:05 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/lib/RCS/text.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/lib/RCS/text.c,v $$Revision: 4.1 $";
  12.  
  13. #include "term.h"
  14.  
  15. #define TRUE    1
  16. #define FALSE    0
  17.  
  18. int
  19. text(s,x,y,font,angle,size_x, size_y)
  20. register char *s;     /* string to be printed */
  21. register int x, y;    /* starting coordinates */
  22. int font;         /* font #, from 0-4 --- 0: line font, 1: seriff type, */
  23.                   /* 2: Greek, 3: cursive, 4: old English             */
  24. int angle;         /* string rotation in degrees */
  25. int size_x;         /* character size  1000 ~= full window sized character */
  26. int size_y;         /* character size  1000 ~= full window sized character */
  27. {
  28.     register char ch;    /* the character being printed */
  29.     register int i;     /* the "workin' man" of variables */
  30.     register int xc,yc;    /* current character coordinates */
  31.     register int penup;    /* a flag */
  32.     short xmax, xmin;    /* maximum character extent */
  33.     short pts[250];         /* vector points */
  34.     int npts;         /* number of vector points */
  35.     int isin(), icos();    /* integer sin, cosine functions */
  36.  
  37.     /* compute scaled x-form data */
  38.  
  39.      int sinx = size_x *isin(angle);
  40.     int cosx = size_x *icos(angle);
  41.      int siny = size_y *isin(angle);
  42.     int cosy = size_y *icos(angle);
  43.  
  44.     if (font > 4 || font < 0)
  45.         font = 0;
  46.  
  47.     while(ch = *s++){ 
  48.         if(font == 0)
  49.             sfont(0,ch,&xmin,&xmax,&npts,pts);
  50.         else
  51.             scribe(font-1,ch,&xmin,&xmax,&npts,pts);
  52.  
  53.         penup = TRUE;          /* pen starts up on each letter */
  54.                 
  55.         for(i=0; i < npts; i += 2)
  56.             if(pts[i] == 31)
  57.                 penup = TRUE;
  58.             else{ 
  59.                 xc = (pts[i]*cosx - pts[i+1]*siny)>>14;
  60.                 yc = (pts[i]*sinx + pts[i+1]*cosy)>>14;
  61.  
  62.                 if(penup)    /* go to the new point */
  63.                     m_go(x + xc, y - yc);
  64.                 else        /* draw to the next point */
  65.                     m_draw(x + xc,y - yc);
  66.                 penup = FALSE;
  67.             }
  68.         x += ((xmax-xmin)*cosx)>>14;
  69.         y -= ((xmax-xmin)*sinx)>>14;
  70.     }
  71. }
  72.